//
//  ImageLabelCell.m
//  QuXiang
//
//  Created by Duncan on 2020/7/11.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "ImageLabelCell.h"

@implementation ImageLabelCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubviews:[NSArray arrayWithObjects:self.titleLabel, self.mainImageView, nil]];
        [self masonryLayout];
    }
    return self;
}

/// 选择房间
- (void)choiseRoomMasLayout {
    [self.mainImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(16));
        make.size.mas_equalTo(kSizzleKapadate(20, 20));
    }];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(16));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(100));
    }];
}

/// 充值中心
- (void)chongzhiMasLayout {
    self.titleLabel.textColor = k_Color_333333;
    self.titleLabel.font = [UIFont systemFontOfSize:kFragmemtFloat(15) weight:UIFontWeightMedium];
    [self.mainImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(16));
        make.size.mas_equalTo(kSizzleKapadate(4, 15));
    }];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.mainImageView.mas_right).offset(kFragmemtFloat(11));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
    }];
}

#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.mainImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(15));
        make.size.mas_equalTo(kFragmemtFloat(15));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.mainImageView.mas_right).offset(kFragmemtFloat(15));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
    }];
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor blackColor];
        [_titleLabel setFont:kAdaptedFontSize(15)];
    }
    return _titleLabel;
}

- (UIImageView *)mainImageView {
    if (!_mainImageView) {
        _mainImageView = [[UIImageView alloc] init];
    }
    return _mainImageView;
}

@end
